import java.util.Scanner;

public class Main1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        String[] array = new String[n];
        int length = 0;
        boolean flag1 = true;
        boolean flag2 = true;

        for (int i = 0; i < n; i++) {
            //1.nextLine
            array[i] = scanner.next();
            if (i > 1) {
                if (array[i].compareTo(array[i - 1]) < 0) {
                    flag2 = false;
                }
            }
            if (array[i].length() < length) {
                flag1 = false;
            }
            length = array[i].length();
        }
        if (flag1 && flag2) {
            System.out.println("both");
        } else if (flag1) {
            System.out.println("lengths");
        } else if (flag2) {
            System.out.println("lexicographically");
        } else {
            System.out.println("none");
        }
    }
}
